/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.cip.esymons.tesoreria.bc;

import java.util.Date;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.tesoreria.be.ComprobanteEgreso;
import org.cip.esymons.tesoreria.be.DetComegreso;
import org.cip.esymons.tesoreria.be.EnumEstadoComprobanteEgreso;

/**
 *
 * @author Administrador
 */
public class ComprobanteEgresoDelegate {
    private ComprobanteEgresoFacadeLocal local;

    public ComprobanteEgresoDelegate() {
        local = lookupComprobanteEgresoFacade();
    }

    public List<ComprobanteEgreso> getListaComprobantes(){
        return local.findAll();
    }

    public List<DetComegreso> listaDetalle(Long codigo) {
        return local.listaDetalle(codigo);
    }

    public List<ComprobanteEgreso> vouchersDisponiblesCajaChica() {
        return local.vouchersDisponiblesCajaChica();
    }

    public List<ComprobanteEgreso> buscarComprobantesEgreso(int tipo, String nombre, String nroVoucher, String nroDocEx, String cuentaEgreso, String banco, Date fecIniG, Date fecFinG, Date fecIniR, Date fecFinR, String numCheque, EnumEstadoComprobanteEgreso estadoComprobanteEgreso) {
        return local.buscarComprobantesEgreso(tipo, nombre, nroVoucher, nroDocEx, cuentaEgreso, banco, fecIniG, fecFinG, fecIniR, fecFinR, numCheque, estadoComprobanteEgreso);
    }

    public ComprobanteEgreso find(Object id) {
        return local.find(id);
    }

    private ComprobanteEgresoFacadeLocal lookupComprobanteEgresoFacade() {
        try {
            Context c = new InitialContext();
            return (ComprobanteEgresoFacadeLocal) c.lookup("java:comp/env/ComprobanteEgresoFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

}
